package com.xy.aggregation;

import com.xy.iterator.ComputerCollegeIterator;
import com.xy.iterator.Department;

import java.util.Iterator;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/17 20:47
 * @description
 */
public class ComputerCollege implements College{
    private Department[] departments;
    private int numOfDepartment = 0; // 对象个数
    private String name;

    @Override
    public String getName() {
        return name;
    }

    public ComputerCollege() {
        departments = new Department[5];
        addDepartment("java专业","java专业");
        addDepartment("Python专业","Python专业");
        addDepartment("PHP专业","PHP专业");
        addDepartment("Go专业","Go专业");
        addDepartment("C++专业","C++专业");
        name = "计算机学院";
    }

    @Override
    public void addDepartment(String name, String desc) {
        Department department = new Department(name, desc);
        departments[numOfDepartment++] = department;
    }

    @Override
    public Iterator<Department> creteIterator() {
        return new ComputerCollegeIterator(departments);
    }
}
